{% extends 'base.html' %}
{% load static %}
{% block title %}添加主机/组{% endblock %}
{% block content %}
    <div>
        <form action="" method="post" class="form-inline">
            {% csrf_token %}
            <div class="form-group">
                <label>主机名：</label>
                <input type="text" class="form-control" name="host">
            </div>
            <div class="form-group">
                <label>ip地址：</label>
                <input type="text" class="form-control" name="ip">
            </div>
            <div class="form-group">
                <label>主机组：</label>
                <input type="text" class="form-control" name="group">
            </div>
            <div class="form-group">
                <input type="submit" class="btn btn-primary" value="提 交">
            </div>
        </form>
    </div>
    <hr>
    <div>
        <table class="table table-bordered table-hover">
            <tr class="info">
                <td>主机组</td>
                <td>主机</td>
            </tr>
            {% for group in groups %}
                <tr>
                    <td>{{ group.group_name }}</td>
                    <td>
                        <ul class="list-unstyled">
                            {% for host in group.host_set.all %}
                                <li>{{ host.hostname }}=>{{ host.ipaddr }}</li>
                            {% endfor %}
                        </ul>
                    </td>
                </tr>
            {% endfor %}

        </table>
    </div>
{% endblock %}